package 慕课网.homework3;

import java.util.Objects;

public class Person {
    private String name;
    private int age;
    private String sex;
    public Person(){

    }
    public Person(String name,int age,String sex){
        this.setAge(age);
        this.setName(name);
        this.setSex(sex);
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        if (sex.equals("女"))
        {
            this.sex = sex;
        }
        else
        {
            this.sex="男";
        }
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "姓名："+this.getName()+"  年龄："+
                this.getAge()+"  性别："+this.getSex();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Person person = (Person) o;
        return age == person.age && Objects.equals(name, person.name) && Objects.equals(sex, person.sex);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age, sex);
    }
}
